package com.eclab.security.core.social.qq.connect;

import com.eclab.security.core.social.qq.api.QQ;
import com.eclab.security.core.social.qq.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

/**
 * 描述:
 * QQ提供商
 * @author yd
 * @create 2019-01-23 15:45
 */

public class QQServiceProvider extends AbstractOAuth2ServiceProvider<QQ> {

    private String appId;

    private static final String URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";

    private static final String URL_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";


    public QQServiceProvider(String appId, String appSecret) {
        super(new QQOAuth2Template(appId,appSecret,URL_AUTHORIZE,URL_ACCESS_TOKEN));
        this.appId = appId;
    }


    @Override
    public QQ getApi(String accessToken) {//不能声明成单例的，不能使用注解直接声明成spring的组件
        return new QQImpl(accessToken ,appId);
    }
}
